﻿@using Microsoft.AspNetCore.Identity
@using Northwind.Infrastructure.Identity
@inject SignInManager<ApplicationUser> SignInManager
@inject UserManager<ApplicationUser> UserManager

@{
    string returnUrl = null;
    var query = ViewContext.HttpContext.Request.Query;
    if (query.ContainsKey("returnUrl"))
    {
        returnUrl = query["returnUrl"];
    }
}

<ul class="navbar-nav px-3 flex-row">
    @if (SignInManager.IsSignedIn(User))
    {
        <li class="nav-item text-nowrap p-2">
            <a class="nav-link" asp-area="Identity" asp-page="/Account/Manage/Index" title="Manage">Hello @User.Identity.Name!</a>
        </li>
        <li class="nav-item text-nowrap p-2">
            <form class="form-inline" asp-area="Identity" asp-page="/Account/Logout" asp-route-returnUrl="/">
                <button type="submit" class="nav-link btn btn-link">Logout</button>
            </form>
        </li>
    }
    else
    {
        <li class="nav-item text-nowrap p-2">
            <a class="nav-link" asp-area="Identity" asp-page="/Account/Register" asp-route-returnUrl="@returnUrl">Register</a>
        </li>
        <li class="nav-item text-nowrap p-2">
            <a class="nav-link" asp-area="Identity" asp-page="/Account/Login" asp-route-returnUrl="@returnUrl">Login</a>
        </li>
    }
</ul>
